#include <iostream>
using namespace std;

class student_t {
  private:
    static int   m_total;  // 静态成员变量
    static float m_points; // 总成绩
  private:
    const char *m_name;
    int         m_age;
    float       m_score;

  public:
    student_t(const char *name, int age, float score);
    void show();

  public:
    static int   getTotal();
    static float getPoints();
};

// 初始化静态成员变量
int   student_t::m_total = 0;
float student_t::m_points = 0.0;

student_t::student_t(const char *name, int age, float score) : m_name(name), m_age(age), m_score(score)
{
    m_total++; // 操作静态成员变量
    m_points += score;
}
void student_t::show()
{
    cout << m_name << "的年龄是" << m_age << "，成绩是" << m_score << "（当前共有" << m_total << "名学生）" << endl;
}

// 定义静态成员函数
int student_t::getTotal()
{
    return m_total;
}
float student_t::getPoints()
{
    return m_points;
}

int main()
{
    // 创建匿名对象
    (new student_t("小明", 15, 90))->show();
    (new student_t("李磊", 16, 80))->show();
    (new student_t("张华", 16, 99))->show();
    (new student_t("王康", 14, 60))->show();

    int   total = student_t::getTotal();
    float points = student_t::getPoints();
    cout << "当前共有" << total << "名学生，总成绩是" << points << "，平均分是" << points / total << endl;

    student_t stu("sumu", 18, 99);
    int       obj_total = stu.getTotal();
    float     obj_points = stu.getPoints();
    cout << "当前共有" << obj_total << "名学生，总成绩是" << obj_points << "，平均分是" << obj_points / obj_total
         << endl;

    return 0;
}
